home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / E32.ZIP / SCRNDIM.ASM < prev    next >
Assembly Source File  |  1994-07-25  |  2KB  |  117 lines

  1. ; SCRNDIM.ASM for E32 - Copyright (C) 1994 Douglas Herr
  2. ;  all rights reserved
  3.  
  4. ; set specified screen dimensions
  5. ; call with AX = screen rows, BX = screen columns
  6.  
  7. include    model.inc
  8.  
  9. public    set_screen_dimensions
  10. public    get_palette, restore_palette
  11.  
  12. extrn    get_screen_data:near
  13.  
  14. extrn    mode43:near, mode29:near, mode12:near
  15. extrn    svga132:near, getcrt:near
  16.  
  17. include    dataseg.inc
  18. extrn    rows:byte, columns:byte
  19. color_dispatch    dd mode43
  20.         dd mode29
  21.         dd dummy
  22.         dd mode12
  23. @curseg    ends
  24.  
  25. include    codeseg.inc
  26. set_screen_dimensions    proc    near
  27.     call    get_palette
  28.     cmp    bx,85        ; separate 132-column modes from others
  29.     ja    short evga132
  30.     push    eax
  31.     mov    ax,3
  32.     cmp    bx,60        ; separate 80- and 40-column modes
  33.     ja    short set80
  34.     mov    ax,1
  35. set80:    int    10h        ; set 40- or 80-column mode, 25 rows
  36.     pop    eax
  37.     xor    ebx,ebx
  38.     cmp    ax,42
  39.     adc    ebx,0        ; BX = 1 if less than 43 rows
  40.     cmp    ax,28
  41.     adc    ebx,0        ; BX = 2 if less than 32 rows
  42.     cmp    ax,24
  43.     adc    ebx,0        ; BX = 3 if less than 25 rows
  44.     call    color_dispatch[ebx*4]
  45.     jmp    short exit
  46.  
  47. evga132:
  48. ; convert AX to SVGA132 index
  49.     mov    ebx,eax
  50.     xor    eax,eax
  51.     sub    bx,26
  52.     jc    short @svga9
  53.     inc    eax
  54.     sub    bx,(35-26)
  55.     jc    short @svga9
  56.     inc    eax
  57.     sub    bx,(45-(33-26))
  58.     jc    short @svga9
  59.     inc    eax
  60.     sub    bx,(55-(45-(33-26)))
  61.     jc    short @svga9
  62.     inc    eax
  63.  
  64. @svga9:    call    svga132
  65.     jnc    short exit
  66.     dec    eax
  67.     jns    @svga9
  68.  
  69. exit:
  70.     call    restore_palette
  71.     call    get_screen_data    ; update E32 data area
  72. dummy:    clc
  73.     ret
  74.  
  75. set_screen_dimensions    endp
  76.  
  77. pal    db 17 dup (0)
  78. get_palette:
  79.     push    eax
  80.     push    edx
  81.     mov    edx,offset pal
  82.     mov    dword ptr [edx],-1
  83.     call    getcrt
  84.     cmp    al,3        ; VGA color?
  85.     je    short its_a_vga
  86.     cmp    ah,3        ; VGA mono?
  87.     jne    short palette_exit
  88. its_a_vga:
  89.     push    ds
  90.     pop    es
  91.     mov    ax,1009h    ; get palette
  92.     int    10h
  93. palette_exit:
  94.     pop    edx
  95.     pop    eax
  96.     ret
  97.  
  98. restore_palette:
  99.     push    eax
  100.     push    ebx
  101.     push    edx
  102.     mov    ebx,offset pal
  103.     push    ds
  104.     pop    es
  105.     cmp    dword ptr [ebx],-1
  106.     je    short r9
  107.     mov    edx,ebx
  108.     mov    ax,1002h
  109.     int    10h
  110. r9:    pop    edx
  111.     pop    ebx
  112.     pop    eax
  113.     ret
  114.  
  115. @curseg    ends
  116.     end
  117.